//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.controller;

import com.example.common.Result;
import com.example.entity.Student;
import com.example.service.StudentService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping({"/student"})
public class StudentController {
    @Resource
    private StudentService studentService;

    public StudentController() {
    }

    @GetMapping({"/selectAll"})
    public Result selectAll(Student student) {
        List<Student> list = this.studentService.selectAll(student);
        return Result.success(list);
    }

    @GetMapping({"/selectById/{id}"})
    public Result selectById(@PathVariable Integer id) {
        Student student = this.studentService.selectById(id);
        return Result.success(student);
    }

    @GetMapping({"/selectList"})
    public Result selectList(Student student) {
        List<Student> list = this.studentService.selectList(student);
        return Result.success(list);
    }

    @GetMapping({"/selectPage"})
    public Result selectPage(Student student, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {
        PageInfo<Student> pageInfo = this.studentService.selectPage(student, pageNum, pageSize);
        return Result.success(pageInfo);
    }

    @PostMapping({"/add"})
    public Result add(@RequestBody Student student) {
        this.studentService.add(student);
        return Result.success();
    }

    @PutMapping({"/updateById"})
    public Result updateById(@RequestBody Student student) {
        this.studentService.updateById(student);
        return Result.success();
    }

    @DeleteMapping({"/deleteById/{id}"})
    public Result deleteById(@PathVariable Integer id) {
        this.studentService.deleteById(id);
        return Result.success();
    }

    @DeleteMapping({"/deleteBatch"})
    public Result deleteBatch(@RequestBody List<Integer> ids) {
        this.studentService.deleteBatch(ids);
        return Result.success();
    }
}
